﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>绑定列表</title>
    <link href="../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/bootstrap-table/src/bootstrap-table.css" rel="stylesheet"
          type="text/css" />
    <link href="../Scripts/bootstrap/css/style.min.css" rel="stylesheet" type="text/css"
          media="all" />
    <link href="../Comm/Style/Table0.css" rel="stylesheet" type="text/css" />

    <script src="../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="../Comm/JS/layer/layer.js" type="text/javascript"></script>
    <link href="../Comm/JS/layer/layer.css" rel="stylesheet" type="text/css" />

    <script src="../Scripts/bootstrap/bootstrap-table/src/bootstrap-table.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap/bootstrap-table/src/locale/bootstrap-table-zh-CN.js"
            type="text/javascript"></script>
    <script src="../Scripts/bootstrap/BootstrapUIDialog.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap/bootstrap-paginator/js/bootstrap-paginator.js"
            type="text/javascript"></script>
    <script src="../Scripts/bootstrap/bootstrap-table/src/colResizable-1.6.min.js"></script>
    <script src="../Scripts/bootstrap/bootstrap-table/src/extensions/resizable/bootstrap-table-resizable.js"></script>
    <script src="../CCForm/MapExt2016.js" type="text/javascript"></script>
    <script src="../Comm/JS/Calendar/WdatePicker.js" type="text/javascript"></script>
    <link href="../Comm/JS/Calendar/skin/WdatePicker.css" rel="stylesheet" type="text/css" />
    <!--<link href="../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../Scripts/easyUI145/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>-->

    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../Scripts/config.js" type="text/javascript"></script>
    <script language="JavaScript" src="../Comm/JScript.js" type="text/javascript"></script>
    <script src="../Scripts/CommonUnite.js" type="text/javascript"></script>
    <!--<script src="../Scripts/EasyUIUtility.js" type="text/javascript"></script>-->
    <script src="../Comm/Gener.js" type="text/javascript"></script>
    <style type="text/css">
        .Wdate {
            border: 1px solid #e5e6e7;
            height: 28px;
        }

        .fixed-table-container thead th .th-inner {
            padding: 8px;
            line-height: 24px;
            vertical-align: top;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap; /**background-color: #eaf2ff;**/
            width: 100%;
        }

        .fixed-table-header {
            background-color: #f2f2f2;
        }

        td {
            word-break: keep-all; /* 不换行 */
            white-space: nowrap; /* 不换行 */
            overflow: hidden; /* 内容超出宽度时隐藏超出部分的内容 */
            text-overflow: ellipsis; /* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用*/
            -o-text-overflow: ellipsis;
            -icab-text-overflow: ellipsis;
            -khtml-text-overflow: ellipsis;
            -moz-text-overflow: ellipsis;
            -webkit-text-overflow: ellipsis;
        }
    </style>
    <script type="text/javascript">
        var sinfo;
        var FilterCtrls = new Array();
        var fk_flow = GetQueryString("FK_Flow");
        var searchType = GetQueryString("SearchType");
        var md;
        var refidx = 0;


        var rptNo = GetQueryString("RptNo");

        //定义公共个变量.
        var webUser = new WebUser();


        //当前用户查询信息.
        var ur = new Entity("BP.Sys.UserRegedit");
        fk_flow = fk_flow.replace(/^0+/, "");
        var rptNo = "ND" + fk_flow + "Rpt" + searchType;
        ur.MyPK = webUser.No + rptNo + "_SearchAttrs";
        ur.RetrieveFromDBSources();
        var Vals = ur.Vals;

        var count;
        var pageIdx = 1;
        var pageSize = 10;
        var pages = 1;//总页数;
        var param = {
            DoType: "FlowSearch_Init",
            SearchType: searchType,
            FK_Flow: fk_flow,
            pageSize: pageSize,
            pageIdx: pageIdx
        };
        var firstLoadTable = false;
        $(function () {
            $("#Msg").html("<img src=../Img/loading.gif />&nbsp;正在加载,请稍后......");
            $("#Msg").show();
            //$("#Msg").css("line-height", $("body").height() / 1.5 + "px");
            //switch (searchType) {
            //    case "My":
            //        $("#dg").datagrid({ title: '我发起的流程' });
            //        break;
            //    case "MyJoin":
            //        $("#dg").datagrid({ title: '我审批的流程' });
            //        break;
            //    case "MyDept":
            //        $("#dg").datagrid({ title: '部门发起的流程' });
            //        break;
            //    case "Adminer":
            //        $("#dg").datagrid({ title: '高级查询' });
            //        break;
            //}
            


            //调用查询返回数据.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
            handler.AddPara("SearchType", searchType);
            handler.AddPara("FK_Flow", GetQueryString("FK_Flow"));
            handler.AddPara("pageSize", pageSize);
            var data = handler.DoMethodReturnString("FlowSearch_Init");

            if (data.indexOf("err@") != -1) {
                alert( data);
                //alert("错误", data, "icon-error");
                return;
            }

            var d = sinfo = eval("(" + data + ")");
            md = d.Sys_MapData[0];
            count = GetPara(md.AtPara, "T_total");//总条数


            if (md.RptIsSearchKey == "1" || (md.RptDTSearchWay && md.RptDTSearchWay != 0) || d.FilterCtrls.length > 0) {
                $("#btn_reset").show();
            }

            pageIdx = param.pageIdx;

            if (count % pageSize != 0)
                pages = parseInt(count / pageSize) + 1;
            else
                pages = parseInt(count / pageSize);
            if (pages == 0) pages = 1;

            //Export();//导出
            Filters(d);//Filters，查询条件
            //给查询条件赋默认值
            var arry = Vals.split("@");
            $.each(arry, function (idx2, val) {
                var val1 = val.split("=");
                $("#" + val1[0]).val(val1[1]);
            });


            BindTable(d)//绑定数据
            $("#Msg").html("");
            $("td").on("mouseover", function () {
                if (this.offsetWidth < this.scrollWidth) {
                    var that = this;
                    var text = $(this).text();
                    layer.tips(text, that, {
                        tips: 1,
                        time: 0
                    });
                }
            });
            $("td").on("mouseout", function () {
                layer.closeAll();
            });

            if (pageIdx == null || pageIdx == undefined || pageIdx == "")
                pageIdx = 1;
            //分页
            Paginator(pages, pageIdx);

        });
        //分页功能
        function Paginator(pageCount, currentPage) {
            var pageCount = pageCount; //取到pageCount的值(把返回数据转成object类型)
            var options = {
                bootstrapMajorVersion: 3, //版本
                currentPage: currentPage, //当前页数
                totalPages: pageCount, //总页数
                shouldShowPage: true, //是否显示该按钮
                itemTexts: function (type, page, current) {
                    switch (type) {
                        case "first":
                            return "首页";
                        case "prev":
                            return "上一页";
                        case "next":
                            return "下一页";
                        case "last":
                            return "末页";
                        case "page":
                            return page;
                    }
                }, //点击事件，用于通过Ajax来刷新整个list列表
                onPageClicked: function (event, originalEvent, type, page) {
                    pageIdx = page;
                    SearchData(page);
                    $('#page_info').html("").append("<li class='disabled controls'>当前第" + pageIdx + "页，总共" + pages +
                        "页,总共" + count + "条记录。</li>");
                }
            };
            $('#page_nav').bootstrapPaginator(options);
            $('#page_info').html("").append("<li class='disabled controls'>当前第" + pageIdx + "页，总共" + pages +
                "页,总共" + count + "条记录。</li>");

        }
        //生成查询页面..
        function BindTable(d) {

            //获取页面的高度
            var H = document.body.clientHeight;
            var tableH = H - $("#tb_main").outerHeight() - $("#page-nav").outerHeight() - 70;

            pageIdx = param.pageIdx;
            pageSize = param.pageSize;


            if (pageIdx == "" || pageIdx == undefined)
                pageIdx = "1";
            if (pageSize == "" || pageSize == undefined)
                pageSize = "10";


            //var mapdata = SearchData();
            //var attrs = mapdata["Attrs"];
            var attrs = d.Sys_MapAttr;
            //var dtMs = mapdata["dtM"];

            var sysMapData = d.Sys_MapData[0];
            sysMapData = new Entity("BP.Sys.MapData", sysMapData); //把他转化成entity.
            var enPK = sysMapData.EnPK;

            if (attrs == undefined) {
                alert('没有取得属性.');
                return;
            }

            var keyOfEn = "";

            var columns = new Array();;
            columns.push({
                title: '序',
                field: '',
                align: 'center',
                width: 25,
                formatter: function (value, row, index) {
                    return pageSize * (pageIdx - 1) + index + 1;    // 返回每条的序号： 每页条数 *（当前页 - 1 ）+ 序号
                }
            });
            for (var i = 0; i < attrs.length; i++) {
                var attr = attrs[i];

                if (attr.No == "OID"
                    || attr.No == "WorkID"
                    || attr.No == "NodeID"
                    || attr.No == "MyNum"
                    || attr.No == "MyPK") {
                    keyOfEn = attr.No
                    continue;
                }


                var field = attr.No;
                var title = attr.Name;
                var width = attr.Width;
                if (width < 60) {
                    width = 60;
                }
                if (field == "Title") {
                     width = 230;
                }
                if (attr.UIContralType == 1) {
                    if (width == null || width == "" || width == undefined)
                        width = 180;
                    //field = field + "Text";
                    columns.push({
                        field: field,
                        title: title,
                        fixed: false,
                        width: width,
                        cellStyle: {
                            css: { "white-space": "nowrap", "word-break": "keep-all", "width": "100%" }
                        }
                    });
                    continue;
                }
                if (attr.UIContralType == 2) {
                    columns.push({
                        field: field,
                        title: title,
                        width: attr.Width,
                        fixed: false,
                        formatter: function (value, row, index) {
                            if (value == "0") return "否";
                            if (value == "1") return "是";
                        }
                    });
                    continue;
                }
                if (width == null || width == "" || width == undefined)
                    width = 100;
                columns.push({
                    field: field,
                    title: title,
                    width: width,
                    fixed: false

                });
            }


            $('#dg').html("");
            $('#dg').bootstrapTable({
                data: d.MainData,
                columns: [columns],
                cache: false,
                striped: true,
                height: tableH,
                singleSelect: true,
                sidePagination: "server",
                pageNumber: 1,
                strictSearch: true,
                //得到查询的参数
                queryParams: function (params) {
                    //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                    var temp = {
                        rows: 10,                         //页面大小
                        page: (count / 10) + 1,   //页码

                    };
                    return temp;
                },

                onDblClickRow: function (row, $element) {
                    
                    var url = '../WorkOpt/OneWork/OneWork.htm?currTab=Frm&WorkID=' + row.OID + '&FK_Flow=' + GetQueryString("FK_Flow") + '&FK_Node=' + row.FlowEndNode + '&FID=' + (row.FID ? row.FID : 0) + '&t=' + Math.random();
                    WinOpen(url);
                }

            });
            $("#dg").colResizable({
                liveDrag: true,
                gripInnerHtml: "<div class='grip'></div>",
                draggingClass: "dragging",
                resizeMode: 'fit',
                //拖动事件
                onDrag: function () {
                    $('#dg').bootstrapTable("resetView")
                }
            });
            firstLoadTable = true;

        }
        function Filters(d) {
            //filters
            var ctrl;
            var fcId;
            var html = "";
            var mapBase = d.Sys_MapData[0];
            var attrs = d.Sys_MapAttr;
            if (mapBase.RptDTSearchWay == "0") {
                if (attrs.length == 0)
                    html += "<table style='width:30%;' >";
                if (attrs.length == 1)
                    html += "<table style='width:50%;' >";
            } else {
                if (attrs.length == 0)
                    html += "<table style='width:60%;' >";
                if (attrs.length == 1)
                    html += "<table style='width:80%;' >";
            }
            if (attrs.length > 1)
                html += "<table style='width:100%;' >";


            html += "<tr>";

            if (mapBase.RptIsSearchKey == "1") {

                html += "<td ><label  style='text-align: right; margin-top:5px;margin-left:5px;' for='TB_Key'>关键字:</label></td>";
                html += "<td ><input style='width:100%;' type=text id='TB_Key' name='TB_Key' value='' class='form-control' /></td>";
                FilterCtrls.push({ type: "text", id: "TB_Key" });
                //$("#tb_main").prepend("<td align='right'><label  style='text-align: right; margin-top:5px;margin-left:5px;' for='TB_Key'>关键字:</label></td>");
                //$("#tb_key").textbox().textbox("setText", md.T_SearchKey);
            }

            if (mapBase.RptDTSearchWay && mapBase.RptDTSearchWay != 0) {

                
                if (mapBase.RptDTSearchWay == 1) {
                    html += "<td ><label style='text-align: right; margin-top:5px;padding-left:20px;'>" + mapBase.T_DateLabel + ":&nbsp;&nbsp</label></td >";
                    html += "<td ><input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + mapBase.T_DTFrom + "'  onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:140px;' class='form-control Wdate' /></td>";
                    html += "&nbsp;&nbsp;<td><label>到:</label>&nbsp;&nbsp<input type=text id='TB_DTTo' name='TB_DTTo' value='" + mapBase.T_DTTo + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:140px;' class='form-control Wdate' /></td>";
                } else {
                    html += "<td ><label style='text-align: right; margin-top:5px;padding-left:20px;'>" + mapBase.T_DateLabel + ":&nbsp;&nbsp</label>";
                    html += "<input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + mapBase.T_DTFrom + "'  onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\" style='width:140px;' class='form-control Wdate' /></td >";
                    html += "&nbsp;&nbsp;<td ><label>到:</label>&nbsp;&nbsp<input type=text id='TB_DTTo' name='TB_DTTo' value='" + mapBase.T_DTTo + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\"  style='width:140px;' class='form-control Wdate' /><td >";
                }
            }



            $.each(d.FilterCtrls, function (idx, c) {

                ctrl = '&nbsp;' + c.Name + ':';
                //ctrl = '<span class="con-span">' + c.Name + ':</span>';
                switch (c.Type) {
                    case "date":
                        html += "<label style='text-align: right; margin-top:5px;padding-left:20px;'>" + mapBase.DTSearchLable + ":&nbsp;&nbsp</label>";
                        html += "<input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + c.DefaultValue + "'  onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:120px;' class='form-control' />";
                        html += "&nbsp;&nbsp;<label>到</label>&nbsp;&nbsp<input type=text id='TB_DTTo' name='TB_DTTo' value='" + c.DefaultValue + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:140px;' class='form-control' />";
                        FilterCtrls.push({ type: c.Type, id: fcId });
                        break;
                    case "datetime":
                        html += "<label style='text-align: right; margin-top:5px;padding-left:20px;'>" + mapBase.DTSearchLable + ":&nbsp;&nbsp</label>";
                        html += "<input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + c.DefaultValue + "'  onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\" style='width:140px;' class='form-control' />";
                        html += "&nbsp;&nbsp;<label>到</label>&nbsp;&nbsp<input type=text id='TB_DTTo' name='TB_DTTo' value='" + c.DefaultValue + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\"  style='width:120px;' class='form-control' />";
                        FilterCtrls.push({ type: c.Type, id: fcId });
                        break;
                    case "text":
                        html += "<td align='right'><label  style='text-align: right; margin-top:5px;margin-left:5px;' for='TB_Key'>" + c.DefaultValue + ":</label></td>";
                        html += "<td align='left'><input style='width:100%;' type=text id='TB_Key' name='TB_Key' value='" + c.DefaultValue + "' class='form-control' /></td>";
                        FilterCtrls.push({ type: c.Type, id: fcId });
                        break;
                    case "combo":
                        fcId = "DDL_" + c.Id;
                        //ctrl += '<select id="' + fcId + '" style="width:150px;">';
                        html += "<td align='right'><label style='text-align: right; margin-top:5px;margin-left:5px;' for='" + fcId + "'>" + c.Name + ":</label></td>";
                        html += "<td ><select class='form-control' id='" + fcId + "'>";

                        $.each(d[c.Id], function (idx1, item) {
                            html += '<option value="' + item[c.ValueField] + '">' + item[c.TextField] + '</option>';
                        });

                        html += '</select></td>';
                       

                        FilterCtrls.push({ type: c.Type, id: fcId });
                        break;
                    case "combotree":
                        fcId = "DDL_" + c.Id;
                        ctrl += '<select id="' + fcId + '" style="width:150px;"></select>';
                        $("#filters").prepend(ctrl);
                        $("#" + fcId).combotree({
                            checkbox: true,
                            multiple: true,
                            data: d[c.Id]
                        });

                        if (c.DefaultValue) {
                            if (c.DefaultValue.indexOf('..') != -1) {
                                var vals = [];
                                $.each(d[c.Id], function (idx1, item) {
                                    if (c.DefaultValue.indexOf('.' + item[c.ValueField] + '.') != -1) {
                                        vals.push(item[c.ValueField]);
                                    }
                                });

                                $("#" + fcId).combotree("setValues", vals);
                            }
                            else {
                                $("#" + fcId).combotree("setValue", c.DefaultValue);
                            }
                        }

                        FilterCtrls.push({ type: c.Type, id: fcId });
                        break;
                    case "checkbox":
                        fcId = "CB_" + c.Id;
                        ctrl += '<input id="' + fcId + '" type="checkbox" />';
                        $("#filters").prepend(ctrl);
                        $("#" + fcId)[0].checked = c.DefaultValue;
                        FilterCtrls.push({ type: c.Type, id: fcId });
                        break;
                    default:
                        break;
                }
            });
            //增加按钮.
            html += '<td align="left" colspan=2 ><a href="#"class="btn btn-primary btn-sm" style="margin-left:20px" id="search_btn" onclick="Search()">查询</a>  ';


            //html += '&nbsp;<a href="#" class="btn btn-default btn-sm" id="new_btn" onclick="Start()">新建</a>';

            html += '&nbsp;<a href="#" class="btn btn-default btn-sm" id="btn_export" onclick="Export()">导出</a>';

            //     if(mapBase.IsImp.toString().toLowerCase() == "true")
            //        html +='&nbsp;<a href="#" class="btn btn-default btn-sm" id="exp_btn" onclick="Imp()">导入</a> ';
            //     if(new WebUser().No=="admin")
            //html +='&nbsp;<a href="#" class="btn btn-default btn-sm" id="setting_btn" onclick="Setting()">设置</a>';

            html += "</td></tr>";

            html += "</table>";
            $("#tb_main").append(html); //设置基础信息.
        }

        function Start() {
            var url = "../../WF/MyFlow.htm?FK_Flow=" + GetQueryString("FK_Flow");
            window.open(url);
        }
        function Export() {

            var key = "";
            var mvals = "";
            var vals = "";
            var val;
            var dtFrom = "";
            var dtTo = "";

            if ($("#tb_key").length > 0) {
                key = $("#tb_key").textbox("getText");
            }

            if ($("#tb_dtFrom").length > 0) {
                dtFrom = $("#tb_dtFrom").textbox("getText");
                dtTo = $("#tb_dtTo").textbox("getText");
            }

            $.each(FilterCtrls, function () {
                switch (this.type) {
                    case "date":
                        val = $("#" + this.id).val();

                        if (val.length > 0) {
                            vals += "@" + this.id + "=" + val;
                        }
                        break;
                    case "datetime":
                        val = $("#" + this.id).val();

                        if (val.length > 0) {
                            vals += "@" + this.id + "=" + val;
                        }
                        break;
                    case "text":
                        val = $("#" + this.id).val();

                        if (val.length > 0) {
                            vals += "@" + this.id + "=" + val;
                        }
                        break;
                    case "combo":
                    case "combotree":
                        val = $("#" + this.id).val();
                        var arry = val.split(",");

                        if (arry.length > 1) {
                            mvals += "@" + this.id.substr("DDL_".length) + "=" + JoinMVals(arry);
                            vals += "@" + this.id + "=mvals";
                        }

                        if (arry.length == 1) {
                            vals += "@" + this.id + "=" + arry[0];
                        }

                        break;
                    case "checkbox":
                        val = $("#" + this.id)[0].checked ? 1 : 0;
                        vals += "@" + this.id + "=" + val;
                        break;
                }
            });
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
            handler.AddPara("SearchType", GetQueryString("SearchType"));
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("key", key);
            handler.AddPara("dtFrom", dtFrom);
            handler.AddPara("dtTo", dtTo);
            handler.AddPara("mvals", mvals);
            handler.AddPara("vals", vals);
            //查询集合
            var data = handler.DoMethodReturnString("FlowSearch_Exp");
            var url = "";
            if (data.indexOf('err@') == 0) {
                alert(data);
            }

            data = basePath + data;
            window.open(data);
            return;
        }
        function SearchData(pageIdx) {
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
            handler.AddUrlData();
            handler.AddPara("pageSize", param.pageSize);
            handler.AddPara("pageIdx", pageIdx);
            var data = handler.DoMethodReturnString("FlowSearch_Done");
            if (data.indexOf("err@") != -1) {
                alert( data);
                //alert("错误", data, "icon-error");
                return;
            }


            data = eval("(" + data + ")");
            md = data.Sys_MapData[0];
            count = GetPara(md.AtPara, "T_total");//总条数
            if (count % pageSize != 0)
                pages = parseInt(count / pageSize) + 1;
            else
                pages = parseInt(count / pageSize);

            if (pages == 0) pages = 1;

            if (firstLoadTable) {
                $('#dg').bootstrapTable("load", data.MainData);

                $("td").on("mouseover", function () {
                    if (this.offsetWidth < this.scrollWidth) {
                        var that = this;
                        var text = $(this).text();
                        layer.tips(text, that, {
                            tips: 1,
                            time: 0
                        });
                    }
                });
                $("td").on("mouseout", function () {
                    layer.closeAll();
                });
                return;
            }
            return data;
        }

        function Search() {
            $("#Msg").show();
            var key = "";
            var mvals = "";
            var vals = "";
            var val;
            var dtFrom = "";
            var dtTo = "";

            if ($("#TB_Key").length > 0) {
                key = $("#TB_Key").val();
            }

            if ($("#TB_DTFrom").length > 0) {
                dtFrom = $("#TB_DTFrom").val();
                dtTo = $("#TB_DTTo").val();
            }

            $.each(FilterCtrls, function () {
                switch (this.type) {
                    case "date":
                        val = $("#" + this.id).val();

                        if (val.length > 0) {
                            vals += "@" + this.id + "=" + val;
                        }
                        break;
                    case "datetime":
                        val = $("#" + this.id).val();

                        if (val.length > 0) {
                            vals += "@" + this.id + "=" + val;
                        }
                        break;
                    case "text":
                        val = $("#" + this.id).val();

                        if (val.length > 0) {
                            vals += "@" + this.id + "=" + val;
                        }
                        break;
                    case "combo":
                    case "combotree":
                        val = $("#" + this.id).val();
                        var arry = val.split(",");

                        if (arry.length > 1) {
                            mvals += "@" + this.id.substr("DDL_".length) + "=" + JoinMVals(arry);
                            vals += "@" + this.id + "=mvals";
                        }

                        if (arry.length == 1) {
                            vals += "@" + this.id + "=" + arry[0];
                        }
                        break;
                    case "checkbox":
                        val = $("#" + this.id)[0].checked ? 1 : 0;
                        vals += "@" + this.id + "=" + val;
                        break;
                }
            });

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptDfine");
            handler.AddPara("SearchType", GetQueryString("SearchType"));
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("key", key);
            handler.AddPara("dtFrom", dtFrom);
            handler.AddPara("dtTo", dtTo);
            handler.AddPara("mvals", mvals);
            handler.AddPara("vals", vals);
            handler.AddPara("pageSize", param.pageSize);
            handler.AddPara("pageIdx", param.pageIdx);
            var data = handler.DoMethodReturnString("FlowSearch_Done");
            if (data.indexOf("err@") != -1) {
                alert( data);
               // alert("错误", data, "icon-error");
                return;
            }


            var d = eval("(" + data + ")");

            md = d.Sys_MapData[0];
            count = GetPara(md.AtPara, "T_total");//总条数
            pageSize = param.pageSize;
            if (count % pageSize != 0)
                pages = parseInt(count / pageSize) + 1;
            else
                pages = parseInt(count / pageSize);

            if (pages == 0) pages = 1;

            //window.location.href = url;
            if (firstLoadTable)
                $('#dg').bootstrapTable("load", d.MainData);
            //分页
            Paginator(pages, param.pageIdx);

        }


        function JoinMVals(mvals) {
            var j = "";

            $.each(mvals, function () {
                j += "." + this + ".";
            });

            return j;
        }

        function Reset() {
            if (md.RptIsSearchKey) {
                $("#tb_key").textbox("clear");
            }

            if (md.RptDTSearchWay != 0) {
                $("#tb_dtFrom").datebox("clear");
                $("#tb_dtTo").datebox("clear");
            }

            $.each(FilterCtrls, function () {
                switch (this.type) {
                    case "date":
                        $("#" + this.id).datebox("clear");
                        break;
                    case "datetime":
                        $("#" + this.id).datetimebox("clear");
                        break;
                    case "text":
                        $("#" + this.id).textbox("clear");
                        break;
                    case "combo":
                    case "combotree":
                        $("#" + this.id).combobox("setValue", "all");
                        break;
                    case "checkbox":
                        $("#" + this.id)[0].checked = false;
                        break;
                }
            });
        }

        function ViewFlow(rowIndex, rowData) {

            if (!rowData && typeof rowIndex != 'undefined') {
                $('#dg').datagrid('selectRow', rowIndex);
                rowData = $('#dg').datagrid('getSelected');
                if (!rowData) return;
            }

            // OpenFrm(rowData.OID,0, fk_flow);
            //  var url = '../WorkOpt/OneWork/OneWork.htm?currTab=Truck&WorkID=' + rowData.OID + '&FK_Flow=' + fk_flow + '&FID=' + (rowData.FID ? rowData.FID : 0) + '&t=' + Math.random();
            var url = '../WorkOpt/OneWork/OneWork.htm?currTab=Frm&WorkID=' + rowData.OID + '&FK_Flow=' + fk_flow + '&FK_Node=' + rowData.FlowEndNode + '&FID=' + (rowData.FID ? rowData.FID : 0) + '&t=' + Math.random();
            // OpenEasyUiDialog(url, 'eudlgframe', '流程轨迹', 1000, 618);
            WinOpen(url);
        }


        function closeDlg() {
            $("#eudlg").dialog("close");
        }
    </script>
    <style type="text/css">
        body {
            margin: 0px;
        }

        .panel-header, .panel-body {
            border-width: 1px;
            border-top: 0px;
            border-left: 0px;
            border-right: 0px;
        }

        .table {
            table-layout: fixed;
        }

        table > td {
            width: 100%;
        }

        .pagination {
            margin: 8px 0;
            display: block;
            font-size: 13px;
        }

            .pagination .controls {
                float: left;
                border: 0;
                padding: 7px 0 0 15px;
                color: #777;
            }
    </style>
</head>
<body id="SearchHtml">
    <div class="wrapper wrapper-content animated fadeInRight" style="padding: 0px 10px 0px 10px">
        <div class="ibox-content">
            <div class="row">
                <div class="panel panel-default" style="border: 0px; margin-bottom: 3px">
                    <div id="tb_main" style="width: 100%">
                        
                    </div>
                </div>
            </div>
            <div class="row">
                <table id="dg" class="table table-hover" style="word-wrap: break-word; word-break: break-all;">
                </table>
            </div>
            <!-- 显示分页信息 -->
            <div class="row" style="text-align: left;">
                <ul class="pagination" id="page_nav">
                </ul>
                <ul class="pagination controls" id="page_info">
                </ul>
                <div style="clear: both;">
                </div>
            </div>
        </div>
        <div id="Msg">
            
        </div>
        
    </div>
</body>
<!--<body class="easyui-layout">
    <div data-options="region:'center',border:false">
        <table class="easyui-datagrid" id="dg" title="我发起的流程" data-options="pageSize:15,pageList:[15,30,50,100],toolbar:'#tb',fit:true,pagination:true,rownumbers:true,singleSelect:true,onDblClickRow:ViewFlow"></table>
    </div>
    <div id="tb" style="padding: 0 15px;">
        <div class="conditions" id="tb_main">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-search"
               id="btn_search" style="display:none; margin-left:5px;">查询</a>
               <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-excel" id="btn_export" style="display:none;">导出</a>
        </div>
		<div class="conditions" id="filters"></div>
    </div>
	<div id="Msg" style="width: 100%; height: 100%; position: absolute; z-index: 999; text-align: center; text-align: center; vertical-align: middle; display: block;">
		<h1><img src='../Img/loading.gif' /> 正在加载请稍候. </h1>
	</div>
</body>-->
</html>
